package com.yami.shop.common.enums;

import java.util.Objects;

/**
 * 支付类型
 *
 * @author yami
 */
public enum PayType {

    /**
     * 积分支付
     */
    SCOREPAY(0, "积分支付"),

    /**
     * 微信支付
     */
    WECHATPAY(1, "小程序支付"),

    /**
     * 支付宝
     */
    ALIPAY(2, "支付宝"),

    /**
     * 微信扫码支付
     */
    WECHATPAY_SWEEP_CODE(3, "微信扫码支付"),

    /**
     * 微信H5支付
     */
    WECHATPAY_H5(4, "微信H5支付"),

    /**
     * 微信公众号
     */
    WECHATPAY_MP(5, "微信公众号支付"),

    /**
     * 支付宝H5支付
     */
    ALIPAY_H5(6, "支付宝H5支付"),

    /**
     * 支付宝APP支付
     */
    ALIPAY_APP(7, "支付宝APP支付"),

    /**
     * 微信APP支付
     */
    WECHATPAY_APP(8, "微信APP支付"),

    /**
     * 余额支付
     */
    BALANCE(9, "余额支付"),

    /**
     * paypal支付
     */
    PAYPAL(10, "paypal支付"),

    HNAPAY_ALI_PAY_H5(11, "新生支付支付宝H5支付"),
    HNAPAY_YSF_PAY_H5(12, "新生支付云闪付H5支付"),
    HNAPAY_ALI_PAY_JS_PAY(13, "新生支付支付宝生活号支付"),
    HNAPAY_WECHAT_PAY_JS_PAY(14, "新生支付微信公众号支付"),
    HNAPAY_KJ(15, "新生支付快捷支付下单")
    ;


    private final Integer num;

    private final String payTypeName;

    public Integer value() {
        return num;
    }

    public String payTypeName() {
        return payTypeName;
    }

    PayType(Integer num, String payTypeName) {
        this.num = num;
        this.payTypeName = payTypeName;
    }

    public static PayType instance(Integer value) {
        PayType[] enums = values();
        for (PayType statusEnum : enums) {
            if (statusEnum.value().equals(value)) {
                return statusEnum;
            }
        }
        return null;
    }

    public static boolean isWxPay(PayType payType) {
        return (Objects.equals(payType, PayType.WECHATPAY) || Objects.equals(payType, PayType.WECHATPAY_SWEEP_CODE) || Objects.equals(payType, PayType.WECHATPAY_H5) || Objects.equals(payType, PayType.WECHATPAY_MP) || Objects.equals(payType, PayType.WECHATPAY_APP));
    }

    public static boolean isAliPay(PayType payType) {
        return (Objects.equals(payType, PayType.ALIPAY_H5) || Objects.equals(payType, PayType.ALIPAY) || Objects.equals(payType, PayType.ALIPAY_APP));
    }

    // public static boolean isUnionPay(PayType payType) {
    //     return (Objects.equals(payType, PayType.UNION_NATIVE) || Objects.equals(payType, PayType.UNION_WEI_XIN_MP_PAY) || Objects.equals(payType, PayType.UNION_WEI_XIN_MINI_PAY) || Objects.equals(payType, PayType.UNION_WEI_XIN_APP_PAY) || Objects.equals(payType, PayType.UNION_ALI_PAY_JS_PAY) || Objects.equals(payType, PayType.UNION_JS_PAY));
    // }

    public static boolean isHnaPay(PayType payType) {
        return (Objects.equals(payType, PayType.HNAPAY_ALI_PAY_H5) || Objects.equals(payType, PayType.HNAPAY_YSF_PAY_H5) || Objects.equals(payType, PayType.HNAPAY_ALI_PAY_JS_PAY) || Objects.equals(payType, PayType.HNAPAY_WECHAT_PAY_JS_PAY) || Objects.equals(payType, PayType.HNAPAY_KJ));
    }
}
